package com.baizhiedu.injection;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * 功能：
 * 作者：HZj
 * 日期：2025/1/5 17:26
 */
@Component
@PropertySource("classpath:init.properties")
public class Category {
    //@Value注解不能应用在静态成员变量上，如果应用，赋值（注入）失败
    @Value("${id}")
    private static Integer id;
    @Value("${name}")
    private String name;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        Category.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Category{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }
}
